﻿using _03_Tank.Properties;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _03_Tank
{
    enum GameState
    {
        Running,
        GameOver
    }

    internal class GameFramework
    {

        public static Graphics g;
        private static GameState gameState = GameState.Running;

        public static void Start()
        {
            SoundManager.InitSound();
            GameObjectManager.Start();
            // 创建地图 创建Boss
            GameObjectManager.CreateMap();

            // 创建主角坦克
            GameObjectManager.CreateMyTank();

            // 开始音效
            SoundManager.PlaySound();
        }

        public static void Update()
        {
            /*GameObjectManager.DrawWall();
            GameObjectManager.DrawTank();*/

            if (gameState == GameState.Running)
            {
                // 渲染内容
                GameObjectManager.Update();
            }
            else if (gameState == GameState.GameOver)
            {
                GameOverUpdate();
            }

        }

        private static void GameOverUpdate()
        {
            Bitmap bmp = Resources.GameOver;
            bmp.MakeTransparent(Color.Black);
            int x = 450 / 2 - Resources.GameOver.Width / 2;
            int y = 450 / 2 - Resources.GameOver.Height / 2;
            g.DrawImage(bmp, x, y);
        }

        public static void ChangeToGameOver()
        {
            gameState = GameState.GameOver;
        }
    }
}
